﻿using Microsoft.Ted.Wacel.TableStorage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Ted.Wacel.DemoDataGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            string storageConnectionString = "[your connection string]";
            CloudTableStorage<Customer> customers = new CloudTableStorage<Customer>("Company", "Id", storageConnectionString, "customers");
            customers.Clear();
            Random rand = new Random();
            for (int i = 0; i < 10000; i++)
            {
                List<Customer> newCustomers1 = new List<Customer>();
                List<Customer> newCustomers2 = new List<Customer>();
                for (int j = 0; j < 100; j++)
                {
                    int index = i * 100 + j + 1;
                    if (index % 2 == 0)
                        newCustomers1.Add(
                        new Customer
                        {
                            Id = string.Format("{0:0000000}", index),
                            Name = "Customer " + index.ToString(),
                            Company = "Company0",
                            Value = rand.Next(0, 99999) / 10.0,
                            Comment = "This is customer " + index.ToString(),
                            ContractDate = DateTime.Now
                        });
                    else
                        newCustomers2.Add(
                        new Customer
                        {
                            Id = string.Format("{0:0000000}", index),
                            Name = "Customer " + index.ToString(),
                            Company = "Company1",
                            Value = rand.Next(0, 99999) / 10.0,
                            Comment = "This is customer " + index.ToString(),
                            ContractDate = DateTime.Now
                        });

                }
                customers.BulkInsertOrReplace(newCustomers1);
                customers.BulkInsertOrReplace(newCustomers2);
                Console.Write(string.Format("{0} ", i*100));
            }
        }
    }
    class Customer
    {
        public string Id { get; set; }
        public string Company { get; set; }
        public string Name { get; set; }
        public double Value { get; set; }
        public string Comment { get; set; }
        public DateTime ContractDate { get; set; }

    }
}
